package org.jetnuke.common;

import org.apache.log4j.Logger;

import net.jforum.dao.DataAccessDriver;
import net.jforum.entities.User;


public class UserInfo implements IUserInfo {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(UserInfo.class);

	User user;

	public UserInfo(User user) {
		this.user = user;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getID()
	 */
	public int getID() {
		if (logger.isDebugEnabled()) {
			logger.debug("getID() - start"); //$NON-NLS-1$
		}

		int returnint = user.getId();
		if (logger.isDebugEnabled()) {
			logger.debug("getID() - end"); //$NON-NLS-1$
		}
		return returnint;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getName()
	 */
	public String getName() {
		if (logger.isDebugEnabled()) {
			logger.debug("getName() - start"); //$NON-NLS-1$
		}

		String returnString = user.getUsername();
		if (logger.isDebugEnabled()) {
			logger.debug("getName() - end"); //$NON-NLS-1$
		}
		return returnString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getUname()
	 */
	public String getUname() {
		if (logger.isDebugEnabled()) {
			logger.debug("getUname() - start"); //$NON-NLS-1$
		}

		String returnString = user.getUsername();
		if (logger.isDebugEnabled()) {
			logger.debug("getUname() - end"); //$NON-NLS-1$
		}
		return returnString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getTheme()
	 */

	// TODO

	public String getTheme() {
		if (logger.isDebugEnabled()) {
			logger.debug("getTheme() - start"); //$NON-NLS-1$
		}

		try {
			String theme = DataAccessDriver.getInstance().newThemeDAO()
					.selectByID(user.getThemeId()).getStyleName();

			if (logger.isDebugEnabled()) {
				logger.debug("getTheme() - end"); //$NON-NLS-1$
			}
			return theme;
		} catch (Exception e) {
			logger.error("getTheme()", e); //$NON-NLS-1$

			if (logger.isDebugEnabled()) {
				logger.debug("getTheme() - end"); //$NON-NLS-1$
			}
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getThemeID()
	 */
	public int getThemeID() {
		if (logger.isDebugEnabled()) {
			logger.debug("getThemeID() - start"); //$NON-NLS-1$
		}

		int returnint = user.getThemeId();
		if (logger.isDebugEnabled()) {
			logger.debug("getThemeID() - end"); //$NON-NLS-1$
		}
		return returnint;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getPrivateMessagesCount()
	 */
	public int getPrivateMessagesCount() {
		if (logger.isDebugEnabled()) {
			logger.debug("getPrivateMessagesCount() - start"); //$NON-NLS-1$
		}

		int returnint = user.getPrivateMessagesCount();
		if (logger.isDebugEnabled()) {
			logger.debug("getPrivateMessagesCount() - end"); //$NON-NLS-1$
		}
		return returnint;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getEMAil()
	 */
	public String getEMAil() {
		if (logger.isDebugEnabled()) {
			logger.debug("getEMAil() - start"); //$NON-NLS-1$
		}

		String returnString = user.getEmail();
		if (logger.isDebugEnabled()) {
			logger.debug("getEMAil() - end"); //$NON-NLS-1$
		}
		return returnString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jetnuke.common.IUserInfo#getThemeId()
	 */
	public int getThemeId() {
		if (logger.isDebugEnabled()) {
			logger.debug("getThemeId() - start"); //$NON-NLS-1$
		}

		int returnint = user.getThemeId();
		if (logger.isDebugEnabled()) {
			logger.debug("getThemeId() - end"); //$NON-NLS-1$
		}
		return returnint;
	}

}
